<#--SQL-->
<?xml version="1.0"?>
<sqllist>
    <sql id="querysql">
	    <select>${querySQL.queryColumns}</select>
        <from>${querySQL.tables}</from>
        <where>${querySQL.where!''}</where>
        <orderby>${querySQL.orderby!''}</orderby>
<#list querySQL.groups as group>
        <group name="${group.groupName!''}" label="${group.groupLabel!''}">
            <groupColumns>${group.groupColumns!''}</groupColumns>
            <aggregateColumns>${group.aggregateColumns!''}</aggregateColumns>
        </group>
</#list>
<#if querySQL.groups?size == 0>
        <group name="" label="">
            <groupColumns></groupColumns>
            <aggregateColumns></aggregateColumns>
        </group>
</#if>
	</sql>

<#if useRecurseQuery==true>
    <sql id="querysqlRecursion">
  <#if dbType=='pgsql' || dbType=='mysql'>
	    <cte>
            ${recursionQuerySQL.cteSql!''}
	    </cte>
  </#if>
	    <select>${recursionQuerySQL.queryColumns}</select>
        <from>${recursionQuerySQL.tables}</from>
        <where>${recursionQuerySQL.where!''}</where>
<#if dbType=='oracle'>
        <orderby siblings="true">${recursionQuerySQL.orderby!''}</orderby>
  <#else>
        <orderby>${recursionQuerySQL.orderby!''}</orderby>
  </#if>
  <#list recursionQuerySQL.groups as group>
        <group name="${group.groupName!''}" label="${group.groupLabel!''}">
            <groupColumns>${group.groupColumns!''}</groupColumns>
            <aggregateColumns>${group.aggregateColumns!''}</aggregateColumns>
        </group>
  </#list>
  <#if recursionQuerySQL.groups?size == 0>
        <group name="" label="">
            <groupColumns></groupColumns>
            <aggregateColumns></aggregateColumns>
        </group>
  </#if>
	</sql>
</#if>
</sqllist>
